<template>
	<div>
		<el-upload
		  :action="imgurl"
		  list-type="picture-card"
		  :on-preview="handlePictureCardPreview"
		  :on-success="handleAvatarSuccess"
		  :on-remove="handleRemove">
		  <i class="el-icon-plus"></i>
		</el-upload>
		<el-dialog :visible.sync="dialogVisible">
		  <img width="100%" :src="dialogImageUrl" alt="">
		</el-dialog>
		<div style="width: 100%; text-align: center;">
			<el-button type="primary" @click="submit">保存</el-button>
		</div>
	</div>
		
</template>
<script type="text/javascript">
	export default {
		props: ['params'],
		components: {
		},
		data() {
			return {
				urls:[],
				 dialogImageUrl: '',
       			 dialogVisible: false,
//				imageUrl: '',
				imgurl:this.$store.state.api + '/user/saveimg',
			}
		},
		methods: {
			  handleRemove(file, fileList) {
		        console.log(file, fileList);
		      },
		      handlePictureCardPreview(file) {
		      	console.log(file,8988);
		        this.dialogImageUrl = file.url;
		        this.dialogVisible = true;
		      },
			  handleAvatarSuccess(res, file) {
			  	this.urls.push(file.response)
			  	console.log(this.urls)
//		        this.imageUrl = file.response
		      },
    		  submit(){
				this.$emit('close', { cancel: true,type:'lbt',list:this.urls})
			  }
		}
	}
</script>
<style lang="less" scoped>
	.avatar-uploader{
		text-align: center;
	}
	 .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 400px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 400px;
    display: block;
  }
</style>